#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m, k;
struct Edge {
  int u, v, rk;
  bool operator<(Edge x) const { return rk < x.rk; }
} a[N];
int rk[N << 1];
int f[N << 1];
int ans[N << 1];
void init() { rep(i, 0, n - 1) f[i] = i, rk[i] = k + 1; }
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
bool merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) {
    f[fy] = fx;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, m) cin >> a[i].u >> a[i].v;
  cin >> k;
  init();
  rep(i, 1, k) {
    int x;
    cin >> x;
    rk[x] = i;
  }
  rep(i, 1, m) a[i].rk = min(rk[a[i].u], rk[a[i].v]);
  sort(a + 1, a + m + 1);
  int j = m;
  int cnt = n;
  per(i, k + 1, 1) {
    while (j && a[j].rk >= i) {
      if (merge(a[j].u, a[j].v)) cnt--;
      j--;
    }
    ans[i] = cnt - i + 1;
  }
  rep(i, 1, k + 1) cout << ans[i] << endl;
  return 0;
}